package org.jili.novoland.base;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;

public class MenuItem extends Layer implements Actor {
    protected int x, y;
    protected Bitmap img;

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public Bitmap getImg() {
        return img;
    }

    public String getName() {
        return name;
    }

    protected String name;

    public MenuItem(int ix, int iy, int iWidth, int iHeight, Bitmap iImg, String iName) {
        super(0, 0, iWidth, iHeight);
        x = ix;
        y = iy;
        img = iImg;
        name = iName;
    }

    public void setPosition(int ix, int iy) {
        x = ix;
        y = iy;
    }

    public boolean checkSelected(int ix, int iy) {
        if (ix >= x && ix <= x + getWidth() && iy >= y && iy <= y + getHeight())
            return true;
        else
            return false;
    }

    @Override
    public void paint(int viewX, int viewY, Canvas c) {
        Rect dstRect = new Rect(x, y, x + getWidth(), y + getHeight());
        Rect srcRect = null;
        if (true) {
            srcRect = new Rect(0, 0, getWidth(), getHeight());
        } else {
            srcRect = new Rect(0, getHeight(), getWidth(), getHeight());
        }
        c.drawBitmap(img, srcRect, dstRect, null);
        c.drawText(name, x, y, new Paint());
    }

    @Override
    public void tick() {
        // TODO Auto-generated method stub

    }
}
